
package org.sopt.dev.ImgKnight.monitor.chart;

import java.awt.Color;
import java.awt.Font;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;

public class DroppedUrlMeter {
	
	private DefaultPieDataset pieDataSet = null;
	
	public DroppedUrlMeter() {
		pieDataSet = new DefaultPieDataset();
		pieDataSet.setValue("Duplicate", 0);
		pieDataSet.setValue("Discard", 0);
	}
	
	public JFreeChart createChart() {
		JFreeChart jfreechart = ChartFactory.createPieChart("Total Dropped URL", 
				pieDataSet, false, true, false);
		PiePlot plot = (PiePlot)jfreechart.getPlot();
		plot.setLabelFont(new Font("SansSerif", 1, 10));
		plot.setNoDataMessage("No data available");
		plot.setCircular(false);
        plot.setLabelGap(0.01);
        jfreechart.setBorderPaint(Color.white);
		jfreechart.setBackgroundPaint(Color.white);
		return jfreechart;
	}
	
	public void setDuplicateValue(double value) {
		pieDataSet.setValue("Duplicate", value);
	}
	
	public void setDiscardValue(double value) {
		pieDataSet.setValue("Discard", value);
	}
}
